package CMPRegistration;

import javax.ejb.*;

/**
 * This is the bean class for the RegistrationBean enterprise bean.
 * Created 19.02.2007 22:52:41
 * @author SANYA
 */
public abstract class RegistrationBean implements EntityBean, RegistrationLocalBusiness {
    private EntityContext context;
    
    // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
    // TODO Consider creating Transfer Object to encapsulate data
    // TODO Review finder methods
    /**
     * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
     */
    public void setEntityContext(EntityContext aContext) {
        context = aContext;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbActivate()
     */
    public void ejbActivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbPassivate()
     */
    public void ejbPassivate() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbRemove()
     */
    public void ejbRemove() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#unsetEntityContext()
     */
    public void unsetEntityContext() {
        context = null;
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbLoad()
     */
    public void ejbLoad() {
        
    }
    
    /**
     * @see javax.ejb.EntityBean#ejbStore()
     */
    public void ejbStore() {
        
    }
    // </editor-fold>
    
    
    public abstract Integer getId();
    public abstract void setId(Integer id);
    
    public abstract String getPassword();
    public abstract void setPassword(String password);
    
    public abstract String getLogin();
    public abstract void setLogin(String login);
    
    public abstract int getUser();
    public abstract void setUser(int user);
    
    public abstract UserregistLocal getUserregistBean();
    public abstract void setUserregistBean(UserregistLocal userregistBean);
    
    
    public Integer ejbCreate(Integer id, String password, String login, int user, UserregistLocal userregistBean)  throws CreateException {
        if (id == null) {
            throw new CreateException("The field \"id\" must not be null");
        }
        if (password == null) {
            throw new CreateException("The field \"password\" must not be null");
        }
        if (login == null) {
            throw new CreateException("The field \"login\" must not be null");
        }
        if (userregistBean == null) {
            throw new CreateException("The field \"userregistBean\" must not be null");
        }
        
        // TODO add additional validation code, throw CreateException if data is not valid
        setId(id);
        setPassword(password);
        setLogin(login);
        setUser(user);
        
        return null;
    }
    
    public void ejbPostCreate(Integer id, String password, String login, int user, UserregistLocal userregistBean) {
        // TODO populate relationships here if appropriate
        setUserregistBean(userregistBean);
        
    }
}
